<div class="bjui-pageHeader">
    <form id="pagerForm" data-toggle="ajaxsearch" action="${request.getContextPath()}/WoStatusAnalysis/woStatusAnalysis"
          method="post">
        <div class="bjui-searchBar">
            <g:hiddenField name="SYS_QUERY_NAME" value="woStatusAnalysis"/>
            <g:hiddenField name="EXPORT_CONTENT_NAME" value="Excel"/>
            <label>批次：</label>
            <input type="text" name="lotId" value="${lotId}" size="17" placeholder="批次"/>&nbsp;
            <label>工序：</label>
            <g:select name="step" from="${woStatusAnalysisStepList}" data-toggle="selectpicker" data-live-search="true"
                      optionKey="step" optionValue="step" value="${step}" data-width="130"
                      noSelection="['': '-- All --']"/>&nbsp;
            <label>存货编码：</label>
            <input type="text" name="partName" value="${partName}" size="17" placeholder="存货编码"/>&nbsp;
            <label>产品名称：</label>
            <input type="text" name="partDesc" value="${partDesc}" size="17" placeholder="产品名称"/>&nbsp;
            <label>状态：</label>
            <g:select name="state" from="${woStatusAnalysisState}" data-toggle="selectpicker" data-live-search="true"
                      optionKey="state" optionValue="state" value="${state}" data-width="130"
                      noSelection="['': '-- All --']"/>
            <br/><br/>
            <label>大组类：</label>
            <g:select name="totalGroup" from="${woStatusAnalysisTotalGroup}" data-toggle="selectpicker"
                      data-live-search="true"
                      optionKey="total_group" optionValue="total_group" value="${totalGroup}" data-width="130"
                      noSelection="['': '-- All --']"/>&nbsp;
            <label>小分类：</label>
            <g:select name="detailCate" from="${woStatusAnalysisDetailCate}" data-toggle="selectpicker"
                      data-live-search="true"
                      optionKey="detail_cate" optionValue="detail_cate" value="${detailCate}" data-width="130"
                      noSelection="['': '-- All --']"/>&nbsp;
            <label>设备：</label>
            <input type="text" name="eqp" value="${eqp}" size="17" placeholder="设备"/>&nbsp;
        %{--<label>批次：</label>
        <g:select name="lotId" from="${woStatusAnalysisLot}" data-toggle="selectpicker" data-live-search="true" optionKey="lot_id" optionValue="lot_id" value="${lotId}" noSelection="['': '===ALL===']"/>&nbsp;
        <label>物料编码：</label>
        <g:select name="partName" from="${woStatusAnalysisPartName}" data-toggle="selectpicker" data-live-search="true" optionKey="part_name" optionValue="part_name" value="${partName}" noSelection="['': '===ALL===']"/>&nbsp;
        <label>产品名称：</label>
        <g:select name="partDesc" from="${woStatusAnalysisPartDesc}" data-toggle="selectpicker" data-live-search="true" optionKey="part_desc" optionValue="part_desc" value="${partDesc}" noSelection="['': '===ALL===']"/>&nbsp;
        <label>工序编码：</label>
        <g:select name="stepName" from="${woStatusAnalysisStepName}" data-toggle="selectpicker" data-live-search="true" optionKey="step_name" optionValue="step_name" value="${stepName}" noSelection="['': '===ALL===']"/>&nbsp;
        <label>工序名称：</label>
        <g:select name="stepDesc" from="${woStatusAnalysisStepDesc}" data-toggle="selectpicker" data-live-search="true" optionKey="step_desc" optionValue="step_desc" value="${stepDesc}" noSelection="['': '===ALL===']"/>&nbsp;
        <label>状态：</label>
        <g:select name="state" from="${woStatusAnalysisState}" data-toggle="selectpicker" data-live-search="true" optionKey="state" optionValue="state" value="${state}" noSelection="['': '===ALL===']"/>&nbsp;--}%

            <label>进站时间：</label>
            <input type="text" name="startTime" readonly value="${startTime}" size="18" data-rule="required"
                   data-pattern="yyyy-MM-dd HH:mm:ss"
                   data-toggle="datepicker" placeholder="FROM">
            <input type="text" name="endTime" readonly value="${endTime}" size="18" data-rule="required"
                   data-pattern="yyyy-MM-dd HH:mm:ss"
                   data-toggle="datepicker" placeholder="TO">
            <br/><br/>
            <button type="submit" class="btn-default" data-icon="search">查询</button>&nbsp;
        %{--<button type="button" class="btn-blue" onclick="javascript:bjuiExportExl('#pagerForm','${request.getContextPath()}/StageWip/exportExcel')" --}%
        %{--data-icon="file-excel-o" title="导出Excel">导出</button>--}%
            <a type="button" class="btn btn-blue" href="${request.getContextPath()}/Base/exportExcel"
               data-toggle="doexport" data-confirm-msg="确定要导出吗？" data-icon="file-excel-o" title="导出Excel">导出</a>
        </div>
    </form>
</div>

<div class="bjui-pageContent tableContent">
    <g:if test="${woStatusAnalysis.size() > 0}">
        <table data-toggle="tablefixed" data-width="100%" data-nowrap="true">
            <thead>
            <tr>
                <g:each in="${tableHeadList}" status="j" var="headInstance">
                    <g:if test="${headInstance != 'RN'}">
                        <th width="150"><g:message code="${headInstance}" default="${headInstance}"/></th>
                    </g:if>
                </g:each>
            </tr>
            </thead>
            <tbody>
            <g:each in="${woStatusAnalysis}" status="i" var="dataInstance">
                <tr>
                    <g:each in="${tableHeadList}" status="j" var="headInstance">
                        <g:if test="${headInstance == 'LOT_ID'}">
                            <td>${dataInstance["${headInstance}"]}</td>
                        </g:if>
                        <g:elseif test="${headInstance == 'MAIN_QTY'}">
                            <td name="lot${i}">${dataInstance["${headInstance}"]}</td>
                        </g:elseif>
                        <g:elseif test="${headInstance == 'STAY_TIME'}">
                            <td name="LOTSTAYTIME${i}">${dataInstance["${headInstance}"]}</td>
                        </g:elseif>
                        <g:elseif test="${headInstance != 'RN'}">
                            <td>${dataInstance["${headInstance}"]}</td>
                        </g:elseif>
                    </g:each>
                </tr>
            </g:each>
            %{-- <tr>
                 <td colspan="12">小计(当前页)</td>
                 <td name="sumLot">0</td>
             </tr>
             <tr>
                 <td colspan="12">合计(总)</td>
                 <td>${woStatusAnalysisSum[0].LOTSUM}</td>

             </tr>--}%
            </tbody>
        </table>
    </g:if>
    <g:else>
        <g:render template="../template/emptyPanel"/>
    </g:else>
</div>

<g:render template="../template/51pagination"/>
<script>
    $(function () {
        /*var sls=0;

        for(var i=0;i<
        ${woStatusAnalysis.size()};i++){
            var sl='lot'+i

            var sumLot=$("td[name='"+sl+"']").text()==''?0:parseInt($("td[name='"+sl+"']").text())

            sls+=sumLot



        }
        $("td[name='sumLot']").html(sls)*/

        for (var i = 0; i <${woStatusAnalysis.size()}; i++) {
            var lotStayTime = "LOTSTAYTIME" + i;
            var lotStayJudge = parseFloat($("td[name='" + lotStayTime + "']").text())
            if (lotStayJudge >= 1 && lotStayJudge < 3) {
                $("td[name='" + lotStayTime + "']").css("background-color", "#FFFF6F")
                $("td[name='" + lotStayTime + "']").nextAll().css("background-color", "#FFFF6F")
                $("td[name='" + lotStayTime + "']").prevAll().css("background-color", "#FFFF6F")

            } else if (lotStayJudge >= 3 && lotStayJudge < 7) {
                $("td[name='" + lotStayTime + "']").css("background-color", "#FF9797")
                $("td[name='" + lotStayTime + "']").nextAll().css("background-color", "#FF9797")
                $("td[name='" + lotStayTime + "']").prevAll().css("background-color", "#FF9797")
            } else if (lotStayJudge >= 7) {
                $("td[name='" + lotStayTime + "']").css("background-color", "#FF5151")
                $("td[name='" + lotStayTime + "']").nextAll().css("background-color", "#FF5151")
                $("td[name='" + lotStayTime + "']").prevAll().css("background-color", "#FF5151")
            }
        }

    })
</script>
